package com.huyi.common.exception;

import com.huyi.common.result.enums.ResultEnum;

/**
 * 自定义业务异常
 * 
 * @author husl
 *
 */
public class BizException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5138560029314253570L;
	private Integer code;
	private String msg;

	/**
	 * 枚举方式
	 * 
	 * @param resultEnum
	 */
	public BizException(ResultEnum resultEnum) {
		this.setCode(resultEnum.getCode());
		this.setMsg(resultEnum.getMsg());
	}
	
	/**
	 * 自定义code
	 * 
	 * @param code
	 * @param msg
	 */
	public BizException(Integer code, String msg) {
		this.setCode(code);
		this.setMsg(msg);
	}

	/**
	 * 固定参数异常返回
	 * 
	 * @param msg
	 */
	public BizException(String msg) {
		this.setCode(ResultEnum.BIZ_ERROR.getCode());
		this.setMsg(msg);
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}
}
